import { WeaSearchGroup,WeaSelect,WeaTools ,WeaErrorPage ,WeaFormItem} from 'ecCom';
import { WeaSwitch } from 'comsMobx';
import {WeaTableNew} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
import isEmpty from 'lodash/isEmpty';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;

class MonitorLogCondition extends React.Component{
    shouldComponentUpdate(){
        return true;
    }
    formParams = {}; 
    render(){
        let group = [];
        const {queryStore} = this.props;
        const { condition,form ,tableStore,dataKey} = queryStore;
        /**常用查询条件 */
        const fixedFormParamsTemp = form.getFormParams();
        for(let param in fixedFormParamsTemp){
          this.formParams[param] = fixedFormParamsTemp[param];
      }
        form.isFormInit && condition.map((v,index) =>{
            let items = [];
            v.items.map(item => {
                items.push({
                    com:(<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@ilh2rq@${item.domkey[0]}`}
                            label={`${item.label}`}
                            labelCol={{span: `${item.labelcol}`}}
                            wrapperCol={{span: `${item.fieldcol}`}}>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@3ngcu7@${item.domkey[0]}`} fieldConfig={item} form={form} formParams={this.formParams} />
                        </WeaFormItem>),
                    colSpan:1
                });
            });
            group.push(<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@docf4v@${index}`} needTigger={true} title={v.title} showGroup={v.defaultshow} items={items}/>);
            group.push(<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@zwr57l@${index}`}
                            title={getLabel(32940,'日志信息')}
                            items={[{
                                com:<WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@e17lj8@log`}
                                        comsWeaTableStore={tableStore} 
                                        hasOrder={true}
                                        needScroll={true} />,
                                col:1
                            }]}
                            showGroup={true}/>);
        });
        
        return <div>{group}</div>;
    }
}

export default WeaTools.tryCatch(React, 
    props => <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@cddzfz`} msg={ props.error ? props.error : getLabel(383324,' 对不起，该页面异常，请联系管理员 ')+'！'} />,
    {error: ""}
)(MonitorLogCondition);